Graphics Primitives (chapter 14)

Various commands are provided to allow control and display of various graphics primitives:

draw string x y string

Draws the character string at the x,y position. x and y are given in inches on the virtual page. The string is drawn using current string attributes -- set the "set string" and "set strsiz" commands.

draw line x1 y1 x2 y2

Draws a line from x1, y1 to x2, y2 using current line drawing attributes. See the "set line" command.

draw rec xlo ylo xhi yhi

Draws an unfilled rectangle from xlo, ylo to xhi, ylo to xhi, yhi to xlo, yhi to xlo, ylo. The rectangle is drawn using current line drawing attributes.

draw recf xlo ylo xhi yhi

Draws a filled rectangle in the area described by xlo, ylo, xhi, yhi. The fill color is the current line drawing attribute color.

draw mark marktype x y size

Draws a marker of type marktype at position x, y at the requested size. Marker types are:

1 - crosshair

2 - open circle

3 - closed circle

4 - open square

5 - closed square

set line color <style> <thickness>

Sets current line attributes. Colors are:

0 - black 5 - cyan

1 - white 6 - magenta

2 - red 7 - yellow

3 - green 8 - orange

4 - blue 15 - grey

styles are:

1 - solid 5 - dotted

2 - long dash 6 - dot dash

3 - short dash 7 - dot dot dash

4 - long, short dashed

Thickness values range from 1 to 6, and provide various line thicknesses on laser printed output.

set string color <justification <thickness <rotation>>>

Sets string drawing attributes. Color is as described above. Justification is the string justification, or how the string is plotted with respect to the x, y position given in the "draw string" command. Refer to the following picture for the appropriate codes:

           tr            tc              tr          tl - top left
            +-------------+--------------+           tc - center top
            |                            |           tr - right top
          l +             + c            + r              etc.
            |                            |
            +-------------+--------------+
           bl             bc             br

The rotation option specifies the desired string rotation in degrees. When rotated, the center of rotation is the justification point. Rotation is counter-clockwise.

set strsiz hsiz <vsiz>

This command sets the string character size, where hsiz is the width of the characters, vsiz is the height of the characters, in virtual page inches. If vsiz is not specified, it will be set the the same value as hsiz.

set rgb color-number red green blue

Defines new colors within GrADS, and assigns them to a new color number. This new color number may then be used within any GrADS command that needs a color number, such as "set ccols".

The color-number must be a value between 16 and 99 (0 to 15 are predefined). The red, green, and blue values must be between 0 and 255. For example:

set rgb 50 255 255 255

Would define a new color number, 50, and assign a color to it. In this case, the color would be white.

The translator gxpsc will make use of the new color settings although the output colors will have to be checked for the desired rendering. gxps will NOT directly translate new colors into greyscales -- instead, it will translate the GREEN intensity ONLY into a new greyscale value. Note that gxps has a predefined mapping between color values from 0 to 15 such that the predefined "rainbow" color effect is rendered as a fairly pleasing greyscale gradation, which cannot be done for newly defined colors.

Plot clipping:

You may specify a clipping area for drawing graphics primitives such as lines and strings. When you do a display command, GrADS sets the clipping region to the parea, draws the graphic, then sets the clipping region to the entire page. Even if you have set the clipping region, a display command will reset it to the entire page. To clip the display of the various draw commands:

set clip xlo xhi ylo yhi

where xlo,xhi,ylo,yhi are the clipping coordinates in real page inches.